package com.mew.chess.core.game.qmcs.game.common;

import com.alibaba.fastjson.JSON;
import com.mew.chess.core.game.qmcs.game.QmcsGameManager;
import com.mew.common.util.TxtUtils;
import lombok.Data;
import lombok.ToString;

import java.util.Arrays;
import java.util.stream.Collectors;

@Data
@ToString
public class QmcsRoute {

    public int lineID;
    public int rootLength;
    public int[] fishType;

    private static String path = "external/roller/qmcs/QmcsLine.json";

    public static void initRoutes(QmcsGameManager gameManager){
        String json = TxtUtils.byFile(path);
        QmcsRoute[] qmcsRoutes = JSON.parseObject(json, QmcsRoute[].class);

        gameManager.setQmcsRoutes(Arrays.stream(qmcsRoutes).collect(Collectors.toList()));

    }

    public static void main(String[] args) {
        String json = TxtUtils.byFile(path);
        QmcsRoute[] qmcsRoutes = JSON.parseObject(json, QmcsRoute[].class);
        for (QmcsRoute qmcsRoute : qmcsRoutes) {
            System.out.println(qmcsRoute);
        }
    }

}
